(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 8.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       157,          7]
NotebookDataLength[     34270,        817]
NotebookOptionsPosition[     31722,        739]
NotebookOutlinePosition[     32278,        760]
CellTagsIndexPosition[     32235,        757]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{

Cell[CellGroupData[{
Cell[TextData[StyleBox["PressureControlledPumpG",
 FontFamily->"System"]], "Section",
 Evaluatable->False,
 CellChangeTimes->{{3.52488616965088*^9, 3.5248861799318666`*^9}, {
   3.549457210515625*^9, 3.54945721375*^9}, {3.54964439396875*^9, 
   3.54964439896875*^9}, 3.576214739734736*^9, {3.6381979342745695`*^9, 
   3.6381979378627744`*^9}, {3.638383908521778*^9, 3.6383839160282073`*^9}}],

Cell[BoxData[
 RowBox[{"<<", "C:\\\\Hopsan\\Compgen\\CompgenNG.mx"}]], "Input",
 CellChangeTimes->{{3.5772037650720577`*^9, 3.5772037650780582`*^9}, {
  3.611474457184202*^9, 3.611474523938877*^9}, {3.6114745588913717`*^9, 
  3.61147456057154*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"path", "=", 
   RowBox[{"ToFileName", "[", 
    RowBox[{"{", 
     RowBox[{
     "\"\<C:\>\"", ",", "\"\<HopsanTrunk\>\"", ",", 
      "\"\<ComponentLibraries\>\"", ",", "\"\<defaultLibrary\>\"", ",", 
      "\"\<Hydraulic\>\"", ",", "\"\<Special\>\""}], "}"}], "]"}]}], 
  ";"}]], "Input",
 CellChangeTimes->{{3.6381979270021534`*^9, 3.6381979307793694`*^9}, 
   3.638201680327718*^9}],

Cell[CellGroupData[{

Cell[BoxData[{
 RowBox[{
  RowBox[{"ResetComponentVariables", "[", "]"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"domain", "=", "\"\<Hydraulic\>\""}], ";"}], "\n", 
 RowBox[{
  RowBox[{"displayName", "=", "\"\<PressureControlledPumpG\>\""}], 
  ";"}], "\n", 
 RowBox[{
  RowBox[{"brief", "=", "\"\<Pressure controlled pump\>\""}], ";"}], "\n", 
 RowBox[{
  RowBox[{"componentType", "=", "\"\<ComponentQ\>\""}], ";"}], "\n", 
 RowBox[{
  RowBox[{"author", "=", "\"\<Petter Krus <petter.krus@liu.se>\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
  "affiliation", " ", "=", " ", 
   "\"\<Division of Fluid and Mechatronic Systems, Link\[ODoubleDot]ping \
University\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"SetFilenames", "[", 
   RowBox[{"path", ",", "domain", ",", "displayName"}], "]"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{"Date", "[", "]"}]}], "Input",
 CellChangeTimes->{{3.5137112151875*^9, 3.513711217109375*^9}, {
   3.51378596903125*^9, 3.513785980671875*^9}, 3.515394539753217*^9, {
   3.515775693875*^9, 3.5157757050625*^9}, {3.517048046727305*^9, 
   3.51704806093043*^9}, 3.51707206725*^9, {3.5176530686834764`*^9, 
   3.51765311057437*^9}, {3.517673126703125*^9, 3.517673126796875*^9}, {
   3.5177214423487377`*^9, 3.517721453114225*^9}, {3.5177222281793466`*^9, 
   3.517722236008023*^9}, {3.5209603293125*^9, 3.520960329578125*^9}, 
   3.521782180515625*^9, {3.52178222675*^9, 3.521782271609375*^9}, {
   3.521782314984375*^9, 3.52178231528125*^9}, 3.5248861854161005`*^9, {
   3.549457222296875*^9, 3.54945722546875*^9}, 3.575772120031607*^9, 
   3.576214746669736*^9, {3.576216089867127*^9, 3.5762161017623167`*^9}, 
   3.576216150378739*^9, {3.6058491003507786`*^9, 3.605849105558299*^9}, {
   3.6381978829096313`*^9, 3.638197911089243*^9}, {3.6383839238506546`*^9, 
   3.6383839375594387`*^9}}],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
  "2015", ",", "9", ",", "7", ",", "14", ",", "45", ",", 
   "15.9073824`8.95417366951752"}], "}"}]], "Output",
 CellChangeTimes->{
  3.6058501946730304`*^9, 3.6199268457661552`*^9, 3.61992699393097*^9, 
   3.6199270798005567`*^9, 3.620451207765235*^9, 3.620451256014167*^9, 
   3.620453360625066*^9, 3.6272821869798875`*^9, 3.6272824413555126`*^9, 
   3.6382014561398954`*^9, 3.638201684250942*^9, 3.638201733106737*^9, 
   3.6382021201008716`*^9, 3.6382021601061597`*^9, {3.638202208297916*^9, 
   3.6382022377716017`*^9}, 3.6382023143969846`*^9, 3.6382023641888323`*^9, 
   3.6382401170548677`*^9, 3.638240273819663*^9, 3.6383504294238834`*^9, 
   3.63835046695903*^9, 3.638364925071987*^9, 3.6383649672563996`*^9, 
   3.638365144700549*^9, 3.638385798720891*^9, 3.638386263685486*^9, 
   3.638388379214487*^9, 3.6384479554840546`*^9, 3.6446890106556377`*^9, 
   3.644689209653536*^9, 3.6506187159183836`*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell["Component description", "Subsection"],

Cell[CellGroupData[{

Cell["\<\
A general pressure controlled pump. The model is based on a linearised model \
but compensated for operating point. The linearised parameters are defined at \
an operating point of nominal pressure \[OpenCurlyDoubleQuote]pnom\
\[CloseCurlyDoubleQuote] and nominal speed \[OpenCurlyDoubleQuote]speednom\
\[CloseCurlyDoubleQuote].\
\>", "Text",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{{3.6058462493056927`*^9, 3.6058462786656284`*^9}, 
   3.6058500540234365`*^9, {3.6383652584960575`*^9, 3.638365341206788*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"Bp", "=."}], ";", 
  RowBox[{"Ap", "=."}], ";", 
  RowBox[{"p0", "=."}], ";"}]], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{{3.54953147675*^9, 3.549531484296875*^9}, {
   3.6058465047642365`*^9, 3.605846513109071*^9}, 3.6058500540234365`*^9}]
}, Closed]]
}, Open  ]],

Cell[CellGroupData[{

Cell["Variables and parameters", "Subsection"],

Cell[BoxData[
 RowBox[{
  RowBox[{"inputVariables", "  ", "=", " ", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"pdif", ",", 
       RowBox[{"2.", " ", 
        SuperscriptBox["10", "7"]}], ",", "double", ",", "\"\<Pa\>\"", ",", 
       "\"\<Reference pressure\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "speed", ",", "157", ",", "double", ",", "\"\<rad/sec\>\"", ",", 
       "\"\<Pump speed\>\""}], "}"}]}], "\[IndentingNewLine]", "}"}]}], 
  ";"}]], "Input",
 CellChangeTimes->{{3.524850755625*^9, 3.524850755640625*^9}, {
   3.5494574883125*^9, 3.54945752521875*^9}, {3.549531806859375*^9, 
   3.54953194565625*^9}, {3.54953217975*^9, 3.549532183765625*^9}, {
   3.549544892890625*^9, 3.54954489334375*^9}, {3.549548144921875*^9, 
   3.54954814540625*^9}, 3.5495483063125*^9, {3.549644405828125*^9, 
   3.5496444085*^9}, 3.576214751415736*^9, {3.576216439434739*^9, 
   3.576216449688739*^9}, {3.576216712838739*^9, 3.576216716478739*^9}, {
   3.576216769119055*^9, 3.576216864499592*^9}, 3.605845980530818*^9, {
   3.605846015044269*^9, 3.6058460162973948`*^9}, 3.605847054209175*^9, {
   3.6381954553627834`*^9, 3.6381954576189127`*^9}, {3.638195515293211*^9, 
   3.638195618900137*^9}, {3.638195654402168*^9, 3.638195685761962*^9}, {
   3.638202097571583*^9, 3.638202108989236*^9}, 3.638202305551479*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"inputParameters", "  ", "=", " ", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
      "rho", ",", "860.", ",", "double", ",", "\"\<kg/m3\>\"", ",", 
       "\"\<oil density\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "qmin", ",", "0.", ",", "double", ",", "\"\<m3/s\>\"", ",", 
       "\"\<Min flow at nom speed\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{"Dp", ",", 
       RowBox[{"3.", " ", 
        SuperscriptBox["10", 
         RowBox[{"-", "4"}]]}], ",", "double", ",", "\"\<m3\>\"", ",", 
       "\"\<Max pump displacement\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "epsmin", ",", "0.", ",", "double", ",", "\"\<\>\"", ",", 
       "\"\<Relative min pump displacement\>\""}], "}"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{"Lp", ",", 
       RowBox[{"1.83", " ", 
        SuperscriptBox["10", "10"]}], ",", "double", ",", "\"\<\>\"", ",", 
       "\"\<Pump inductance\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{"Rp", ",", 
       RowBox[{"1.68", " ", 
        SuperscriptBox["10", "10"]}], ",", "double", ",", "\"\<\>\"", ",", 
       "\"\<Pump resistance\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "wp1", ",", "13.3", ",", "double", ",", "\"\<rad/sec\>\"", ",", 
       "\"\<Reg break freq\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{"Kcp", ",", 
       RowBox[{"0.1", " ", 
        SuperscriptBox["10", 
         RowBox[{"-", "11"}]]}], ",", "double", ",", "\"\<\>\"", ",", 
       "\"\<Pump speed\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "tauv", ",", "0.05", ",", "double", ",", "\"\<s\>\"", ",", 
       "\"\<Time c of control valve\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "Tp", ",", "0.001", ",", "double", ",", "\"\<s\>\"", ",", 
       "\"\<Time min-full disp\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "Tm", ",", "0.001", ",", "double", ",", "\"\<s\>\"", ",", 
       "\"\<Time full-min disp\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{"pnom", ",", 
       RowBox[{"7.", " ", 
        SuperscriptBox["10", "6"]}], ",", "double", ",", "\"\<pa\>\"", ",", 
       "\"\<Nominal pressure\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "speednom", ",", "157", ",", "double", ",", "\"\<rad/s\>\"", ",", 
       "\"\<Nominal speed\>\""}], "}"}]}], "\[IndentingNewLine]", "}"}]}], 
  ";"}]], "Input",
 CellChangeTimes->{{3.6381956958705397`*^9, 3.638195721281993*^9}, {
   3.6381969755697346`*^9, 3.638197291049779*^9}, {3.638197683877247*^9, 
   3.638197873466091*^9}, 3.6382401131860733`*^9, {3.638350250390643*^9, 
   3.6383502930650835`*^9}, {3.638383818321619*^9, 3.638383873030748*^9}, {
   3.6383862286034794`*^9, 3.6383862594502435`*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"outputVariables", "  ", "=", " ", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
      "qp", ",", "0.", ",", "double", ",", "\"\<m^3/s\>\"", ",", 
       "\"\<Pump flow\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "dqp", ",", "0.", ",", "double", ",", "\"\<m^3/s^2\>\"", ",", 
       "\"\<Pump flow rate of change\>\""}], "}"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "eps", ",", "0.", ",", "double", ",", "\"\<\>\"", ",", 
       "\"\<Relative pump stroke\>\""}], "}"}]}], "\[IndentingNewLine]", 
    "}"}]}], ";"}]], "Input",
 CellChangeTimes->{{3.54953165409375*^9, 3.549531724296875*^9}, {
   3.576217056639804*^9, 3.5762170731454544`*^9}, {3.6058460077685413`*^9, 
   3.605846008521617*^9}, {3.605846648737632*^9, 3.605846653236082*^9}, {
   3.6272834624324713`*^9, 3.6272835203750954`*^9}, {3.6381956415294313`*^9, 
   3.638195650450942*^9}, {3.638196958944783*^9, 3.6381969640050726`*^9}, 
   3.638202155409891*^9, {3.638384277164863*^9, 3.638384340801503*^9}, {
   3.6384479091114025`*^9, 3.638447941521256*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"nodeConnections", "=", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"HydraulicQnode", "[", 
      RowBox[{"1", ",", 
       RowBox[{"1.", "*", 
        RowBox[{"10", "^", "5"}]}], ",", "\"\<inlet port 1\>\""}], "]"}], ",",
      "    \t", 
     RowBox[{"HydraulicQnode", "[", 
      RowBox[{"2", ",", 
       RowBox[{"1.", "*", 
        RowBox[{"10", "^", "5"}]}], ",", "\"\<outlet port 2\>\""}], "]"}], 
     ",", "    \t", 
     RowBox[{"HydraulicQnode", "[", 
      RowBox[{"3", ",", 
       RowBox[{"1.", "*", 
        RowBox[{"10", "^", "5"}]}], ",", "\"\<pressure sensing node 3\>\""}], 
      "]"}]}], "}"}]}], ";"}]], "Input",
 CellChangeTimes->{{3.524850747078125*^9, 3.524850747078125*^9}, {
  3.54945737746875*^9, 3.54945738609375*^9}, {3.6381969249388385`*^9, 
  3.638196941529787*^9}, {3.638197307870741*^9, 3.638197362352857*^9}}]
}, Open  ]],

Cell[CellGroupData[{

Cell["The system of equations", "Subsection"],

Cell[TextData[StyleBox["There migtht be variables that one whishes to treat \
as constants when computing the Jacobian.  In order to be treated as \
constants they can be defined as local expressions. Local expressions are \
treated as constants when the Jacobian is calculated.\nIn this example Lpe \
and Rpe are nearly constant but it is sligthly dependent on p2 but not to the \
extent that it is worth the considerable extra effort it would have meant to \
bring that in when the Jacobian was extracted.",
 FontFamily->"Times"]], "Text",
 Evaluatable->False,
 CellChangeTimes->{{3.638365209692266*^9, 3.638365234859706*^9}},
 FontFamily->"Times New Roman"],

Cell["\<\
eps is used as a small number to avoid singularity at zero speed\
\>", "Text",
 CellChangeTimes->{{3.638364844620385*^9, 3.638364888427891*^9}}],

Cell[BoxData[{
 RowBox[{
  RowBox[{"del", "=", "0.1"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"speede", "=", 
   RowBox[{"lowLimit", "[", 
    RowBox[{"speed", ",", "del"}], "]"}]}], ";"}]}], "Input",
 CellChangeTimes->{{3.638364826310338*^9, 3.638364840649158*^9}, {
  3.6384478539672484`*^9, 3.638447871442248*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"localExpressions", "=", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"qmine", "\[Equal]", 
      RowBox[{"epsmin", " ", 
       FractionBox["Dp", 
        RowBox[{"2", " ", "pi"}]], " ", "speed"}]}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"qmaxe", "\[Equal]", 
      RowBox[{
       FractionBox["Dp", 
        RowBox[{"2", " ", "pi"}]], " ", "speed"}]}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"dqmin", "\[Equal]", 
      RowBox[{
       RowBox[{"-", 
        FractionBox[
         RowBox[{"qmaxe", "-", "qmine"}], "Tm"]}], 
       RowBox[{"sqrt", "[", 
        RowBox[{"p2", "/", "pnom"}], "]"}]}]}], " ", ",", 
     "\[IndentingNewLine]", 
     RowBox[{"dqmax", "==", 
      RowBox[{
       FractionBox[
        RowBox[{"qmaxe", "-", "qmine"}], "Tp"], 
       RowBox[{"sqrt", "[", 
        RowBox[{"p2", "/", "pnom"}], "]"}]}]}], ",", "\[IndentingNewLine]", 
     RowBox[{"Lpe", "\[Equal]", 
      RowBox[{"Lp", " ", 
       RowBox[{"sqrt", "[", 
        RowBox[{"pnom", "/", "p2"}], "]"}], " ", 
       FractionBox["speednom", "speede"]}]}], ",", "\[IndentingNewLine]", 
     RowBox[{"Rpe", "\[Equal]", 
      RowBox[{"Rp", " ", 
       RowBox[{"sqrt", "[", 
        RowBox[{"pnom", "/", "p2"}], "]"}], " ", 
       FractionBox["speednom", "speede"]}]}], ",", "\[IndentingNewLine]", 
     RowBox[{"wp1e", "\[Equal]", 
      RowBox[{"wp1", "  ", 
       FractionBox["speede", "speednom"]}]}]}], "\[IndentingNewLine]", 
    "}"}]}], ";"}]], "Input",
 CellChangeTimes->{{3.6382410497498956`*^9, 3.638241068679681*^9}, {
   3.6383503458811045`*^9, 3.638350392197754*^9}, {3.6383504571944714`*^9, 
   3.638350457605495*^9}, {3.638364752445113*^9, 3.638364812374541*^9}, {
   3.6383648948402576`*^9, 3.638364909969123*^9}, {3.638365096083768*^9, 
   3.6383651414603634`*^9}, {3.6383837628384457`*^9, 
   3.6383838089560833`*^9}, {3.638383891837824*^9, 3.638383899150242*^9}, {
   3.6383855772112217`*^9, 3.6383855785853004`*^9}, 3.6383857279678445`*^9, {
   3.638388340924297*^9, 3.6383883593313494`*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"systemEquationsDA", ":=", " ", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"dqp", "==", 
      FractionBox[
       RowBox[{"s", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{"-", "p2"}], "+", "p3", "+", "pdif"}], ")"}], " ", 
        RowBox[{"(", 
         RowBox[{"1", "+", 
          FractionBox["s", "wp1e"]}], ")"}]}], 
       RowBox[{
        RowBox[{"(", 
         RowBox[{
          RowBox[{"Lpe", " ", "s"}], "+", "Rpe"}], ")"}], " ", 
        RowBox[{"(", 
         RowBox[{"1", "+", 
          RowBox[{"s", " ", "tauv"}]}], ")"}]}]]}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"der", "[", "qp", "]"}], "==", "dqp"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"q2", "==", 
      RowBox[{"qp", "+", 
       RowBox[{
        RowBox[{"(", 
         RowBox[{"p1", "-", "p2"}], ")"}], " ", "Kcp"}]}]}]}], 
    "\[IndentingNewLine]", "}"}]}], ";"}]], "Input",
 CellChangeTimes->{{3.524850724265625*^9, 3.524850724265625*^9}, 
   3.549457307015625*^9, {3.549457351265625*^9, 3.54945736171875*^9}, {
   3.549457392*^9, 3.549457398203125*^9}, {3.54945742834375*^9, 
   3.549457482296875*^9}, {3.5494575509375*^9, 3.549457556703125*^9}, 
   3.549526952765625*^9, {3.549532039546875*^9, 3.549532058125*^9}, {
   3.54953211190625*^9, 3.5495321299375*^9}, {3.549532235765625*^9, 
   3.549532235828125*^9}, {3.549544864359375*^9, 3.549544883234375*^9}, {
   3.549548317125*^9, 3.549548322796875*^9}, {3.549548688859375*^9, 
   3.549548692421875*^9}, {3.5719033502092543`*^9, 3.571903383796113*^9}, {
   3.5762147596047363`*^9, 3.576214789346736*^9}, 3.576214838815736*^9, 
   3.5762149233297358`*^9, {3.619926327818366*^9, 3.6199263453261166`*^9}, {
   3.6199264105686398`*^9, 3.619926433744958*^9}, 3.61992699032561*^9, {
   3.6204511896243567`*^9, 3.620451192149871*^9}, 3.6204533530323067`*^9, 
   3.627282818142028*^9, {3.638196710049547*^9, 3.6381968109703197`*^9}, 
   3.6381979924828987`*^9, 3.638201717704856*^9, {3.638240423672515*^9, 
   3.638240431557243*^9}, {3.6383503946378937`*^9, 3.638350406034545*^9}, 
   3.63835046241077*^9, {3.6383839784307766`*^9, 3.6383840221252756`*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"expressions", " ", "=", " ", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"q1", "\[Equal]", 
      RowBox[{"-", "q2"}]}], ",", "\[IndentingNewLine]", 
     RowBox[{"p3", "==", "c3"}], ",", "\[IndentingNewLine]", 
     RowBox[{"q3", "\[Equal]", "0."}], ",", "\[IndentingNewLine]", 
     RowBox[{"eps", "\[Equal]", 
      FractionBox["qp", "qmaxe"]}]}], "\[IndentingNewLine]", "}"}]}], 
  ";"}]], "Input",
 CellChangeTimes->{{3.54952682025*^9, 3.54952686515625*^9}, {
   3.5719034223281803`*^9, 3.571903426477788*^9}, 3.6058465630910683`*^9, {
   3.6381979883096595`*^9, 3.6381979969791555`*^9}, {3.638202344420702*^9, 
   3.638202350783066*^9}, 3.638202387533168*^9, {3.6382404514351625`*^9, 
   3.638240457837001*^9}, {3.6384478375203075`*^9, 3.6384478421015697`*^9}, {
   3.638447880676776*^9, 3.6384478984897947`*^9}}],

Cell["Limitatons", "Text",
 CellChangeTimes->{{3.524850848515625*^9, 3.524850857984375*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"variableLimits", "=", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"dqp", ",", "dqmin", ",", "dqmax"}], "}"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{"qp", ",", "qmine", ",", "qmaxe"}], "}"}]}], 
    "\[IndentingNewLine]", "}"}]}], ";"}]], "Input",
 CellChangeTimes->{{3.521781710359375*^9, 3.521781715921875*^9}, 
   3.521781911703125*^9, {3.521782089203125*^9, 3.521782090109375*^9}, {
   3.549457539921875*^9, 3.54945754465625*^9}, {3.6204511996503687`*^9, 
   3.620451201998777*^9}, {3.620451236567506*^9, 3.6204512444282193`*^9}, {
   3.6381767238014526`*^9, 3.638176727488821*^9}, {3.6381968717607965`*^9, 
   3.6381968978592896`*^9}, {3.6383841156416245`*^9, 3.638384168446645*^9}, {
   3.638384478943404*^9, 3.6383844837026763`*^9}, {3.6383846523513227`*^9, 
   3.6383846525253325`*^9}, {3.6383847940144253`*^9, 3.638384803282955*^9}, {
   3.638384914415312*^9, 3.6383849253549376`*^9}, {3.6383850819008913`*^9, 
   3.638385085850117*^9}, {3.638385223118969*^9, 3.638385246659315*^9}, {
   3.6383853854912558`*^9, 3.638385399974084*^9}}],

Cell["The boundarys", "Text"],

Cell[BoxData[
 RowBox[{
  RowBox[{"systemBoundaryEquations", " ", "=", " ", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"p1", "==", 
      RowBox[{"c1", "+", 
       RowBox[{"Zc1", " ", "q1"}]}]}], ",", "\[IndentingNewLine]", 
     RowBox[{"p2", "==", 
      RowBox[{"c2", "+", 
       RowBox[{"Zc2", " ", "q2"}]}]}]}], "\[IndentingNewLine]", "}"}]}], 
  ";"}]], "Input",
 CellChangeTimes->{{3.52485078196875*^9, 3.52485078196875*^9}, {
  3.549457268203125*^9, 3.549457269234375*^9}, {3.5494574144375*^9, 
  3.549457415609375*^9}, {3.5719034112833614`*^9, 3.5719034182409735`*^9}, {
  3.594115692243491*^9, 3.5941157083961067`*^9}, {3.63819742866965*^9, 
  3.638197442347432*^9}, {3.638197956701852*^9, 3.638197980470211*^9}, {
  3.6382404826578846`*^9, 3.638240507909026*^9}}],

Cell["The  vector of independent variables of the system are", "Text",
 CellChangeTimes->{{3.524850810625*^9, 3.52485083609375*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"systemVariables", "=", " ", 
   RowBox[{"{", 
    RowBox[{"dqp", ",", "qp", ",", "q2", ",", "p1", ",", "p2"}], "}"}]}], 
  ";"}]], "Input",
 CellChangeTimes->{{3.524850716875*^9, 3.524850716875*^9}, {
   3.54952696459375*^9, 3.54952699509375*^9}, {3.62045124783226*^9, 
   3.6204512532355003`*^9}, {3.6381973813599443`*^9, 3.638197399856002*^9}, 
   3.6381980066467085`*^9, {3.638384071666109*^9, 3.638384073173196*^9}}],

Cell["Dealing with cavitation", "Text",
 CellChangeTimes->{{3.6382405203885098`*^9, 3.638240532041497*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"variableLowLimits", "=", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"p1", ",", "0"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"p2", ",", "0"}], "}"}]}], "}"}]}], ";"}]], "Input",
 CellChangeTimes->{{3.578505814681842*^9, 3.5785058445435495`*^9}, 
   3.578509359037567*^9, 3.638175877546835*^9, {3.6381974076994505`*^9, 
   3.6381974114296637`*^9}}],

Cell["\<\
Generating C++ component model for Hopsan simulation.\
\>", "Text",
 CellChangeTimes->{{3.638240544607032*^9, 3.6382405652033825`*^9}, {
  3.6385001573418975`*^9, 3.638500163542828*^9}}],

Cell[BoxData[
 RowBox[{"Compgen", "[", "file", "]"}]], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{3.6058500608243685`*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"Part", "::", "partd"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"Part specification \[NoBreak]\\!\\(delayedPart \
\[LeftDoubleBracket] \\(\\(1, 1\\)\\) \[RightDoubleBracket]\\)\[NoBreak] is \
longer than depth of object. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \
ButtonStyle->\\\"Link\\\", ButtonFrame->None, \
ButtonData:>\\\"paclet:ref/message/General/partd\\\", ButtonNote -> \
\\\"Part::partd\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.6506187161754093`*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"Part", "::", "partd"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"Part specification \[NoBreak]\\!\\(delayedPart \
\[LeftDoubleBracket] \\(\\(1, 2\\)\\) \[RightDoubleBracket]\\)\[NoBreak] is \
longer than depth of object. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \
ButtonStyle->\\\"Link\\\", ButtonFrame->None, \
ButtonData:>\\\"paclet:ref/message/General/partd\\\", ButtonNote -> \
\\\"Part::partd\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.6506187161794095`*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"Part", "::", "partd"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"Part specification \[NoBreak]\\!\\(delayedPart \
\[LeftDoubleBracket] \\(\\(2, 1\\)\\) \[RightDoubleBracket]\\)\[NoBreak] is \
longer than depth of object. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \
ButtonStyle->\\\"Link\\\", ButtonFrame->None, \
ButtonData:>\\\"paclet:ref/message/General/partd\\\", ButtonNote -> \
\\\"Part::partd\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.6506187161804094`*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"General", "::", "stop"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"Further output of \[NoBreak]\\!\\(\\*StyleBox[\\(Part :: \
partd\\), \\\"MessageName\\\"]\\)\[NoBreak] will be suppressed during this \
calculation. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \
ButtonStyle->\\\"Link\\\", ButtonFrame->None, \
ButtonData:>\\\"paclet:ref/message/General/stop\\\", ButtonNote -> \
\\\"General::stop\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.65061871618141*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"XMLElement", "::", "cntsList"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"\[NoBreak]\\!\\(XMLElement[\\(\\(\\\"modelobject\\\", \
\\(\\({\\(\[LeftSkeleton] 1 \[RightSkeleton]\\)}\\)\\), \
\\(\\({\\(\\(XMLElement[\\(\\(\\\"icon\\\", \\(\\({\\(\\(\\\"isopath\\\" \
\[Rule] \\\"HydraulicPressureControlledPumpG.svg\\\"\\)\\), \
\\(\\(\\\"iconrotation\\\" \[Rule] \\\"ON\\\"\\)\\), \\(\\(\\\"userpath\\\" \
\[Rule] \\\"HydraulicPressureControlledPumpG.svg\\\"\\)\\)}\\)\\), \
\\(\\({}\\)\\)\\)\\)]\\)\\), \\(\\(XMLElement[\\(\\(\\\"portpositions\\\", \
\\(\\({}\\)\\), \\(\\({\\(\\(XMLElement[\\(\\(\\\"portpose\\\", \\(\\(\
\[LeftSkeleton] 1 \[RightSkeleton]\\)\\), \\(\\({}\\)\\)\\)\\)]\\)\\), \\(\\(\
\[LeftSkeleton] 6 \[RightSkeleton]\\)\\), \\(\\(XMLElement[\\(\\(\\\"portpose\
\\\", \\(\\({\\(\[LeftSkeleton] 1 \[RightSkeleton]\\)}\\)\\), \
\\(\\({}\\)\\)\\)\\)]\\)\\)}\\)\\)\\)\\)]\\)\\)}\\)\\)\\)\\)]\\)\[NoBreak] in \
\[NoBreak]\\!\\(XMLElement[\\(\\(\[LeftSkeleton] 1 \[RightSkeleton]\\)\\)]\\)\
\[NoBreak] is not a list of contents. The third item in an XMLElement must be \
a list of contents, even if it is an empty list. \\!\\(\\*ButtonBox[\\\"\
\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", ButtonFrame->None, \
ButtonData:>\\\"paclet:ref/XMLElement\\\", ButtonNote -> \
\\\"XMLElement::cntsList\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.6506187162064123`*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"Export", "::", "autofix"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"Malformed symbolic XML expression encountered. This may \
result in unexpected XML data. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \
ButtonStyle->\\\"Link\\\", ButtonFrame->None, \
ButtonData:>\\\"paclet:ref/Export\\\", ButtonNote -> \\\"Export::autofix\\\"]\
\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.650618716208412*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"XMLElement", "::", "attrhs"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"\[NoBreak]\\!\\(0.25`\\)\[NoBreak] in \
\[NoBreak]\\!\\(\\\"y\\\" \[Rule] 0.25`\\)\[NoBreak] is not a valid value for \
an attribute in an XMLElement. The value of the attribute must be a string. \
\\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", \
ButtonFrame->None, ButtonData:>\\\"paclet:ref/XMLElement\\\", ButtonNote -> \
\\\"XMLElement::attrhs\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.650618716210413*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"Export", "::", "autofix"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"Malformed symbolic XML expression encountered. This may \
result in unexpected XML data. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \
ButtonStyle->\\\"Link\\\", ButtonFrame->None, \
ButtonData:>\\\"paclet:ref/Export\\\", ButtonNote -> \\\"Export::autofix\\\"]\
\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.650618716212413*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"XMLElement", "::", "attrhs"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"\[NoBreak]\\!\\(0.5`\\)\[NoBreak] in \[NoBreak]\\!\\(\\\"y\
\\\" \[Rule] 0.5`\\)\[NoBreak] is not a valid value for an attribute in an \
XMLElement. The value of the attribute must be a string. \
\\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", \
ButtonFrame->None, ButtonData:>\\\"paclet:ref/XMLElement\\\", ButtonNote -> \
\\\"XMLElement::attrhs\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.6506187162134132`*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"Export", "::", "autofix"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"Malformed symbolic XML expression encountered. This may \
result in unexpected XML data. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \
ButtonStyle->\\\"Link\\\", ButtonFrame->None, \
ButtonData:>\\\"paclet:ref/Export\\\", ButtonNote -> \\\"Export::autofix\\\"]\
\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.650618716215413*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"General", "::", "stop"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"Further output of \[NoBreak]\\!\\(\\*StyleBox[\\(Export :: \
autofix\\), \\\"MessageName\\\"]\\)\[NoBreak] will be suppressed during this \
calculation. \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \
ButtonStyle->\\\"Link\\\", ButtonFrame->None, \
ButtonData:>\\\"paclet:ref/message/General/stop\\\", ButtonNote -> \
\\\"General::stop\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.6506187162164135`*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"XMLElement", "::", "attrhs"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"\[NoBreak]\\!\\(0.75`\\)\[NoBreak] in \
\[NoBreak]\\!\\(\\\"y\\\" \[Rule] 0.75`\\)\[NoBreak] is not a valid value for \
an attribute in an XMLElement. The value of the attribute must be a string. \
\\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", \
ButtonFrame->None, ButtonData:>\\\"paclet:ref/XMLElement\\\", ButtonNote -> \
\\\"XMLElement::attrhs\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.6506187162174134`*^9}],

Cell[BoxData[
 RowBox[{
  StyleBox[
   RowBox[{"General", "::", "stop"}], "MessageName"], 
  RowBox[{
  ":", " "}], "\<\"Further output of \
\[NoBreak]\\!\\(\\*StyleBox[\\(XMLElement :: attrhs\\), \
\\\"MessageName\\\"]\\)\[NoBreak] will be suppressed during this calculation. \
\\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", \
ButtonFrame->None, ButtonData:>\\\"paclet:ref/message/General/stop\\\", \
ButtonNote -> \\\"General::stop\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{3.638385798928903*^9, 3.638386263882497*^9, 
  3.638388379461501*^9, 3.638447956732126*^9, 3.6446890109156637`*^9, 
  3.6446892098695574`*^9, 3.6506187162194138`*^9}]
}, Open  ]]
}, Open  ]]
},
WindowSize->{797, 690},
WindowMargins->{{51, Automatic}, {Automatic, 28}},
PrintingCopies->1,
PrintingPageRange->{32000, 32000},
PrintingOptions->{"Magnification"->1.,
"PaperOrientation"->"Portrait",
"PaperSize"->{582.9599999999999, 829.0799999999999}},
Magnification->1.100000023841858,
FrontEndVersion->"8.0 for Microsoft Windows (64-bit) (October 6, 2011)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[579, 22, 391, 6, 77, "Section",
 Evaluatable->False],
Cell[973, 30, 248, 4, 32, "Input"],
Cell[1224, 36, 421, 11, 53, "Input"],
Cell[CellGroupData[{
Cell[1670, 51, 1867, 38, 193, "Input"],
Cell[3540, 91, 952, 16, 32, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[4529, 112, 43, 0, 40, "Subsection"],
Cell[CellGroupData[{
Cell[4597, 116, 551, 9, 49, "Text",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}],
Cell[5151, 127, 315, 7, 75, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}]
}, Closed]]
}, Open  ]],
Cell[CellGroupData[{
Cell[5515, 140, 46, 0, 40, "Subsection"],
Cell[5564, 142, 1395, 26, 99, "Input"],
Cell[6962, 170, 3078, 70, 331, "Input"],
Cell[10043, 242, 1171, 25, 113, "Input"],
Cell[11217, 269, 901, 22, 93, "Input"]
}, Open  ]],
Cell[CellGroupData[{
Cell[12155, 296, 45, 0, 44, "Subsection"],
Cell[12203, 298, 660, 10, 114, "Text",
 Evaluatable->False],
Cell[12866, 310, 154, 3, 30, "Text"],
Cell[13023, 315, 330, 8, 53, "Input"],
Cell[13356, 325, 2077, 50, 332, "Input"],
Cell[15436, 377, 2188, 47, 163, "Input"],
Cell[17627, 426, 877, 17, 164, "Input"],
Cell[18507, 445, 92, 1, 30, "Text"],
Cell[18602, 448, 1151, 21, 93, "Input"],
Cell[19756, 471, 29, 0, 30, "Text"],
Cell[19788, 473, 800, 17, 93, "Input"],
Cell[20591, 492, 132, 1, 30, "Text"],
Cell[20726, 495, 455, 9, 32, "Input"],
Cell[21184, 506, 107, 1, 30, "Text"],
Cell[21294, 509, 410, 11, 32, "Input"],
Cell[21707, 522, 196, 4, 30, "Text"],
Cell[21906, 528, 160, 3, 32, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}],
Cell[22069, 533, 676, 13, 23, "Message"],
Cell[22748, 548, 676, 13, 23, "Message"],
Cell[23427, 563, 676, 13, 23, "Message"],
Cell[24106, 578, 669, 13, 23, "Message"],
Cell[24778, 593, 1584, 25, 119, "Message"],
Cell[26365, 620, 600, 12, 23, "Message"],
Cell[26968, 634, 717, 13, 43, "Message"],
Cell[27688, 649, 600, 12, 23, "Message"],
Cell[28291, 663, 717, 13, 43, "Message"],
Cell[29011, 678, 600, 12, 23, "Message"],
Cell[29614, 692, 676, 13, 23, "Message"],
Cell[30293, 707, 719, 13, 43, "Message"],
Cell[31015, 722, 679, 13, 23, "Message"]
}, Open  ]]
}, Open  ]]
}
]
*)

(* End of internal cache information *)
